Skip to content

Conversation

@HHR2020
Copy link
Contributor

@HHR2020 HHR2020 commented Dec 2, 2025

Add typ2docx, a tool to convert typst to docx.

python3Packages.{saxonche, pdfservices-sdk} are added as dependencies.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@HHR2020 HHR2020 marked this pull request as draft December 2, 2025 15:43
@sghng
Copy link

sghng commented Dec 3, 2025

@HHR2020 I have a feeling that it's because we didn't do the inclusion of lock file in the appropriate way. The whole point of Nix is about reproducibility, there's no way that CI is "stricter" (everything should be strict).

Maybe you should do search for examples on how other packages are doing this kind of patching/additional file inclusion? I LLM gave me some hints but I'm not sure if they are valid.

@sghng
Copy link

sghng commented Dec 3, 2025

Also, it might be a good idea to ask if Adobe/Saxonica are willing to maintain the dependencies.

I don't think Adobe is taking care of their Python SDK based on what I see in the codebase. But Saxonica's developers are very responsive. I can help create a ticket in their issue tracker.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 6.topic: python Python is a high-level, general-purpose programming language. labels Dec 3, 2025
@HHR2020
Copy link
Contributor Author

HHR2020 commented Dec 3, 2025

@HHR2020 I have a feeling that it's because we didn't do the inclusion of lock file in the appropriate way. The whole point of Nix is about reproducibility, there's no way that CI is "stricter" (everything should be strict).

The current way of lock file inclusion is not appropriate as it triggers import from derivation, which is enabled by default but not allowed in nixpkgs because it slows down the evaluation.

Finally I found a solution in nixpkgs manual, it turns out that fetchCargoVendor allows patching.

Also, it might be a good idea to ask if Adobe/Saxonica are willing to maintain the dependencies.

The 2 dependencies are quite easy to maintain(as bots will help making update prs; it would be better if Saxonica distribute a source package instead of wheels though). Asking upstream developer to maintain sounds odd to me if they don't use nix, but it's good to hear that Saxonica devs are responsive.

So, I think this pr is ready, but we need to wait until #454434 gets into master

@HHR2020

This comment was marked as outdated.

@sghng
Copy link

sghng commented Dec 3, 2025

@HHR2020 could you also submit a PR to typ2docx to include Nix install in README?

@HHR2020
Copy link
Contributor Author

HHR2020 commented Dec 4, 2025

@HHR2020 could you also submit a PR to typ2docx to include Nix install in README?

Yes, I'll create one after this pr gets merged

@sghng
Copy link

sghng commented Dec 7, 2025

@HHR2020 seems like the click dependency update is merged into master already

@HHR2020
Copy link
Contributor Author

HHR2020 commented Dec 8, 2025

@HHR2020 seems like the click dependency update is merged into master already

Not really, it's still in staging, and it will be manually merged to staging-next first. It usually takes 2~4 weeks to create a staging-next => master pr, the last staging-next => master pr was on 2025-11-14, so let's be patient.

I noticed 0.8.0 is released, I'll update the pr later.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/openssl-error-during-uv-tool-install-typ2docx/73074/2

@HHR2020
Copy link
Contributor Author

HHR2020 commented Dec 10, 2025

It seems that someone is already using the package on NixOS, so I updated the typ2docx to 0.8.0 and patched the files to make it work with old python3Packages.click in nixpkgs.

@HHR2020

This comment was marked as outdated.

@HHR2020 HHR2020 marked this pull request as ready for review December 10, 2025 05:50
@nixpkgs-ci nixpkgs-ci bot requested a review from natsukium December 10, 2025 05:51
@sghng
Copy link

sghng commented Dec 10, 2025

It seems that someone is already using the package on NixOS, so I updated the typ2docx to 0.8.0 and patched the files to make it work with old python3Packages.click in nixpkgs.

If you're referring to the recent post in NixOS forum, it was installed via uv, so it's irrelevant I guess?

The problem with the patch is, it functions the same, but users won't see that flag in the help doc.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: module (update) This PR changes an existing module in `nixos/` and removed 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Dec 10, 2025
@nixpkgs-ci nixpkgs-ci bot added the 8.has: documentation This PR adds or changes documentation label Dec 10, 2025
@HHR2020
Copy link
Contributor Author

HHR2020 commented Dec 10, 2025

If you're referring to the recent post in NixOS forum, it was installed via uv, so it's irrelevant I guess?

Yes, I'm suggesting him to use this pr, because saxonche can't work without patchelf, which means it has to be packaged in nixpkgs.

The problem with the patch is, it functions the same, but users won't see that flag in the help doc.

Are the flags expected, or it misses something?

tb% ./result/bin/typ2docx --help                                  
                                                                                                                                                    
 Usage: typ2docx [OPTIONS] INPUT [-- TYPST_OPT...]                                                                                                  
                                                                                                                                                    
 Convert a Typst project to DOCX format.                                                                                                            
                                                                                                                                                    
╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *    input           PATH               Entry point to the Typst project [required]                                                              │
│      typst_opts      [-- TYPST_OPT...]  Options forwarded to the Typst compiler (must follow --).                                                │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *  --engine              -e      [acrobat|pdfservices|pdf2docx]  The engine used to convert PDF to DOCX. [required]                              │
│    --output              -o      PATH                            Output DOCX file path. [default: (input.with_suffix('.docx'))]                  │
│    --debug               -d                                      Keep intermediate files in working directory for inspection.                    │
│    --install-acrobat                                             Install trusted functions for Adobe Acrobat.                                    │
│    --install-completion                                          Install completion for the current shell.                                       │
│    --show-completion                                             Show completion for the current shell, to copy it or customize the              │
│                                                                  installation.                                                                   │
│    --help                                                        Show this message and exit.                                                     │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: module (update) This PR changes an existing module in `nixos/` labels Dec 10, 2025
@sghng
Copy link

sghng commented Dec 10, 2025

If you're referring to the recent post in NixOS forum, it was installed via uv, so it's irrelevant I guess?

Yes, I'm suggesting him to use this pr, because saxonche can't work without patchelf, which means it has to be packaged in nixpkgs.

The problem with the patch is, it functions the same, but users won't see that flag in the help doc.

Are the flags expected, or it misses something?


tb% ./result/bin/typ2docx --help                                  

                                                                                                                                                    

 Usage: typ2docx [OPTIONS] INPUT [-- TYPST_OPT...]                                                                                                  

                                                                                                                                                    

 Convert a Typst project to DOCX format.                                                                                                            

                                                                                                                                                    

╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮

│ *    input           PATH               Entry point to the Typst project [required]                                                              │

│      typst_opts      [-- TYPST_OPT...]  Options forwarded to the Typst compiler (must follow --).                                                │

╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮

│ *  --engine              -e      [acrobat|pdfservices|pdf2docx]  The engine used to convert PDF to DOCX. [required]                              │

│    --output              -o      PATH                            Output DOCX file path. [default: (input.with_suffix('.docx'))]                  │

│    --debug               -d                                      Keep intermediate files in working directory for inspection.                    │

│    --install-acrobat                                             Install trusted functions for Adobe Acrobat.                                    │

│    --install-completion                                          Install completion for the current shell.                                       │

│    --show-completion                                             Show completion for the current shell, to copy it or customize the              │

│                                                                  installation.                                                                   │

│    --help                                                        Show this message and exit.                                                     │

╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Never mind, it should be the same. I thought changing [] to None will change the arg type hint but seems like it looks the same.

@HHR2020 HHR2020 changed the title typ2docx: init at 0.7.0; python3Packages.{saxonche, pdfservices-sdk}: init typ2docx: init at 0.8.0; python3Packages.{saxonche, pdfservices-sdk}: init Dec 10, 2025
@HHR2020

This comment was marked as outdated.

@HHR2020 HHR2020 force-pushed the typ2docx branch 2 times, most recently from 8dbc540 to dead822 Compare December 14, 2025 12:13
@HHR2020 HHR2020 requested a review from dotlambda December 14, 2025 12:21
@HHR2020
Copy link
Contributor Author

HHR2020 commented Dec 14, 2025

@dotlambda Thanks for your detailed review, I added an update script and it should be OK now.

@HHR2020 HHR2020 added 8.has: package (new) This PR adds a new package and removed 8.has: documentation This PR adds or changes documentation labels Dec 14, 2025
@HHR2020
Copy link
Contributor Author

HHR2020 commented Dec 14, 2025

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 467150
Commit: dead822ad1da033ee5066f5df2c163ab4fd4f216 (subsequent changes)
Merge: d0ebfae6c1d831c5756f45b280d1d5f632997800

Logs: https://github.com/HHR2020/nixpkgs-review-gha/actions/runs/20208111187


x86_64-linux

✅ 10 packages built:
  • python312Packages.pdfservices-sdk
  • python312Packages.pdfservices-sdk.dist
  • python312Packages.saxonche
  • python312Packages.saxonche.dist
  • python313Packages.pdfservices-sdk
  • python313Packages.pdfservices-sdk.dist
  • python313Packages.saxonche
  • python313Packages.saxonche.dist
  • typ2docx
  • typ2docx.dist

aarch64-linux

✅ 10 packages built:
  • python312Packages.pdfservices-sdk
  • python312Packages.pdfservices-sdk.dist
  • python312Packages.saxonche
  • python312Packages.saxonche.dist
  • python313Packages.pdfservices-sdk
  • python313Packages.pdfservices-sdk.dist
  • python313Packages.saxonche
  • python313Packages.saxonche.dist
  • typ2docx
  • typ2docx.dist

x86_64-darwin (sandbox = true)

✅ 10 packages built:
  • python312Packages.pdfservices-sdk
  • python312Packages.pdfservices-sdk.dist
  • python312Packages.saxonche
  • python312Packages.saxonche.dist
  • python313Packages.pdfservices-sdk
  • python313Packages.pdfservices-sdk.dist
  • python313Packages.saxonche
  • python313Packages.saxonche.dist
  • typ2docx
  • typ2docx.dist

aarch64-darwin (sandbox = true)

✅ 10 packages built:
  • python312Packages.pdfservices-sdk
  • python312Packages.pdfservices-sdk.dist
  • python312Packages.saxonche
  • python312Packages.saxonche.dist
  • python313Packages.pdfservices-sdk
  • python313Packages.pdfservices-sdk.dist
  • python313Packages.saxonche
  • python313Packages.saxonche.dist
  • typ2docx
  • typ2docx.dist

@HHR2020
Copy link
Contributor Author

HHR2020 commented Dec 31, 2025

Click 8.3.1 has been merged into master, so I cleaned up the code and rebased this pr onto master.
@dotlambda , would you be up for a quick re-review?

@HHR2020
Copy link
Contributor Author

HHR2020 commented Dec 31, 2025

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 467150
Commit: 972caed5371c8481bb8fb0dc66577ae9849d4e06 (subsequent changes)
Merge: 3a1ba32e02cb10a0ce5733bc0f94dc054e747915

Logs: https://github.com/HHR2020/nixpkgs-review-gha/actions/runs/20614517549


x86_64-linux

✅ 10 packages built:
  • python313Packages.pdfservices-sdk
  • python313Packages.pdfservices-sdk.dist
  • python313Packages.saxonche
  • python313Packages.saxonche.dist
  • python314Packages.pdfservices-sdk
  • python314Packages.pdfservices-sdk.dist
  • python314Packages.saxonche
  • python314Packages.saxonche.dist
  • typ2docx
  • typ2docx.dist

aarch64-linux

✅ 10 packages built:
  • python313Packages.pdfservices-sdk
  • python313Packages.pdfservices-sdk.dist
  • python313Packages.saxonche
  • python313Packages.saxonche.dist
  • python314Packages.pdfservices-sdk
  • python314Packages.pdfservices-sdk.dist
  • python314Packages.saxonche
  • python314Packages.saxonche.dist
  • typ2docx
  • typ2docx.dist

x86_64-darwin (sandbox = true)

✅ 10 packages built:
  • python313Packages.pdfservices-sdk
  • python313Packages.pdfservices-sdk.dist
  • python313Packages.saxonche
  • python313Packages.saxonche.dist
  • python314Packages.pdfservices-sdk
  • python314Packages.pdfservices-sdk.dist
  • python314Packages.saxonche
  • python314Packages.saxonche.dist
  • typ2docx
  • typ2docx.dist

aarch64-darwin (sandbox = true)

✅ 10 packages built:
  • python313Packages.pdfservices-sdk
  • python313Packages.pdfservices-sdk.dist
  • python313Packages.saxonche
  • python313Packages.saxonche.dist
  • python314Packages.pdfservices-sdk
  • python314Packages.pdfservices-sdk.dist
  • python314Packages.saxonche
  • python314Packages.saxonche.dist
  • typ2docx
  • typ2docx.dist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose programming language. 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants